import { legacy_createStore ,combineReducers } from "redux"
// combineReducers 链接器
function mesSlice1(state = {num:0}, action) {
    switch (action.type) {
        case "add":
            return { ...state, num: state.num + action.payload }
        case "sub":
            return { ...state, num: state.num - action.payload }
        case "change":
            return { ...state, num: action.payload }
        default:
            return {...state}
    }
}


function mesSlice2(state = {num:0}, action) {
    switch (action.type) {
        case "add":
            return { ...state, num: state.num + action.payload }
        case "sub":
            return { ...state, num: state.num - action.payload }
        case "change":
            return { ...state, num: action.payload }
        default:
            return {...state}
    }
}

let redus = combineReducers({
          mesSlice1,
          mesSlice2
})

let store = legacy_createStore(redus)
export default store